<?php 
$sql_ult_fotos = mysql_query("SELECT id_topico,arquivo,descricao FROM tbl_arquivos WHERE id_topico != '' ORDER BY id DESC");
$sql_fotos_rows = mysql_num_rows($sql_ult_fotos);
if($sql_fotos_rows > 0){

?>
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="coolcarousel/jquery.carouFredSel-6.0.4-packed.js" type="text/javascript"></script>
<script type="text/javascript">
	function redir_noticia(codigo){
		window.location= 'noticias_page&noticia='+codigo;
	}
	$(function() {
		$('#wrapper').hover(
			function() {
				
				$('#carousel').trigger( 'pause' );
				$('#thumbnails').parent().animate({
					top: 230
				});
			}, function() {
				
				
				$('#carousel').trigger( 'play' );
				$('#thumbnails').parent().animate({
					top: 325
				});
			}
		);

		$('#carousel').carouFredSel({
			scroll: {
				fx: 'crossfade',
				onBefore: function( data ) {
					$('#thumbnails').trigger( 'slideTo', [ $('#thumbnails img[alt='+ data.items.visible.attr( 'alt' ) +']'), -2 ] );
				},
			}
			
		});
		$('#thumbnails').carouFredSel({
			auto: false,
			width:599.9,
			items: {
				start: -2
			},
			

		});

		$('#thumbnails img').click(function() {
			$('#carousel').trigger( 'slideTo', [ $('#carousel img[alt='+ $(this).attr( 'alt' ) +']') ] );
		}).css( 'cursor', 'pointer' );
	});
</script>
<style type="text/css">
			#wrapper {
				width: 540px;
				height: 350px;
				/*margin: -200px 0 0 -300px;*/
				overflow: hidden;
				position: relative;
				float:left;
				left: 0px;
				top: 10px;
				/*box-shadow: 0 10px 15px #333;*/
				border:15px solid  #c0c0c0;
			}
			#carousel {
				width: 545px;
				height: 350px;
				overflow: hidden;
				position: absolute;
				top: 0;
				left: 0;
			}
			#carousel img {
				display: block;
				float: left;
			}
			#thumbnails {
				width: 560px;
				height: 120px;
				overflow: hidden;
				position: absolute;
				top: 325px;
				left: -58px;
				z-index: 2;
				background-image:url(img/barra_slide.png);
			}
			#thumbnails img {
				display: block;
				float: left;
				margin: 10px;
				width: 100px;
				height: 100px;
				box-shadow: 0 0 10px #000;
			}
			#thumbnails img:hover {
				width: 110px;
				height: 110px;
				margin: 5px;
			}

</style>
<?php 
$lista = '';
$cont = 0;

$sql_notice = mysql_query("SELECT id,titulo,foto_principal,descricao_foto,texto,fonte FROM tbl_noticias WHERE foto_principal != '' ORDER BY id DESC LIMIT 5");
$linhas = mysql_num_rows($sql_notice);
while(list($codigo,$tituloN,$foto_principal,$descricao_foto,$texto,$fonte)=mysql_fetch_array($sql_notice)){
	$lista[$cont]['foto_principal'] = $foto_principal;
	$lista[$cont]['id_topico'] = $codigo;
	$lista[$cont]['descricao'] = $tituloN;
	$cont++;
}
/*while(list($id_topico,$arquivo,$descricao)=mysql_fetch_array($sql_ult_fotos)){// galeria de fotos.
	$lista[$cont]['arquivo'] = $arquivo;
	$lista[$cont]['id_topico'] = $id_topico;
	$lista[$cont]['descricao'] = $descricao;
	$cont++;
}*/
?>
<div style="margin-left:10px;margin-top:10px;float:left;width:95%;border-bottom:1px solid #da814b;padding-bottom:5px;">
<font color="#da814b" face="Tahoma, Geneva, sans-serif" size="+1">Destaque</font>
</div>

<div id="wrapper">
    <div id="carousel">
    <?php 
		for($x=0;$x<count($lista);$x++){
	?>
	   <!-- <img src="fotos/fotos/<?php echo $lista[$x]['foto_principal']; ?>" alt="c10" width="600" height="360" />-->
        <img src="noticias/fotos/<?php echo $lista[$x]['foto_principal']; ?>" onclick="redir_noticia('<?php echo base64_encode($lista[$x]['id_topico']); ?>');" alt="c<?php echo $x; ?>" width="540" height="360" />
	<?php } ?>
    </div>
    <div id="thumbnails">
    <?php 
		for($x=0;$x<count($lista);$x++){
	?>
	    <!--<img src="fotos/thumb/<?php echo $lista[$x]['foto_principal']; ?>" alt="c11" width="100" height="100" />-->
        <img src="noticias/thumb/<?php echo $lista[$x]['foto_principal']; ?>" alt="c<?php echo $x; ?>" width="100" height="100" />
	<?php } ?>
    </div>
</div>
<?php } ?>